package com.yunshipei.core.utils;

import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;

public class ViewUtils {

    public static TextureView findXWalkTextureView(ViewGroup group) {

        int childCount = group.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View child = group.getChildAt(i);
            if (child instanceof TextureView) {
                String parentClassName = child.getParent().getClass().toString();
                boolean isRightKindOfParent = (parentClassName.contains("XWalk"));
                if (isRightKindOfParent) {
                    return (TextureView) child;
                }
            } else if (child instanceof ViewGroup) {
                TextureView textureView = findXWalkTextureView((ViewGroup) child);
                if (textureView != null) {
                    return textureView;
                }
            }
        }
        return null;
    }
}
